Skip to content

fix: preserve bootstrap_impl in exec config - #4477

Open
StephanDollberg wants to merge 2 commits into
bazel-contrib:mainfrom
StephanDollberg:bootstrap-impl-universal-scope
Open

StephanDollberg wants to merge 2 commits into
bazel-contrib:mainfrom
StephanDollberg:bootstrap-impl-universal-scope

Conversation

@StephanDollberg

Copy link
Copy Markdown

With Bazel 10, --bootstrap_impl=script no longer applies to Python
executables built as tools, e.g. a py_binary run by a genrule. They
fall back to system_python and fail to start on hosts without a
python3.

Give the flag universal scope, as 159b6c2 did for python_version and
05916c1 for venvs_use_declare_symlink.

With Bazel 10, `--bootstrap_impl=script` no longer applies to Python
executables built as tools, e.g. a `py_binary` run by a `genrule`. They
fall back to `system_python` and fail to start on hosts without a
`python3`.

Give the flag universal scope, as 159b6c2 did for `python_version` and
05916c1 for `venvs_use_declare_symlink`.
Copilot AI balanced review requested due to automatic review settings November 11, 2026 14:07
@StephanDollberg

Copy link
Copy Markdown
Author

PR was created with AI help, I'll be responding to comments myself.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The existing genrule tests do not cover command-line bootstrap flag propagation into the exec configuration, leaving a regression test with a plain py_binary tool under Bazel 10 needed.

1 open issue
What changed in this PR

Preserves --bootstrap_impl across Bazel 10 exec transitions so Python build tools honor the selected bootstrap instead of reverting to system_python.

Changes:

  • Adds a scope attribute to rules_python’s string build-setting rule.
  • Gives bootstrap_impl universal scope so its value propagates to build tools.
  • Documents the behavior and adds a release note.
File Description
python/​private/​flags.bzl Exposes the Bazel-recognized scope attribute.
python/​config_settings/​BUILD.bazel Sets universal scope for bootstrap_impl.
news/​bootstrap-impl-exec-config.fixed.md Announces the Bazel 10 build-tool bootstrap fix.
docs/​api/​rules_python/​python/​config_settings/​index.md Documents flag propagation to exec configurations.

Review effort: Balanced

# configuration. Bazel 10 resets Starlark flags in exec configurations
# unless they have universal scope
# (https://github.com/bazelbuild/bazel/issues/26909).
scope = "universal",

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do if maintainers agree.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes please, a test for this would be good.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added

Builds a py_binary genrule tool with --bootstrap_impl=script set on the
command line and checks that it gets the script bootstrap.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants